﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.Configuration;
using TGIApp.Model;

namespace TGIApp.Web.Controllers
{
    public class TicketTypeController : Controller
    {
        //
        // GET: /TicketType/

        public ActionResult Index()
        {
            var proxy = new Proxy.ServiceProxy();
            var ticketTypes = proxy.GetAllTicketTypes();
            return View(ticketTypes);
        }

        //
        // GET: /TicketType/Details/5

        public ActionResult Details(int id)
        {
            var proxy = new Proxy.ServiceProxy();
            var ticketType = proxy.GetTicketTypeById(id);
            return View(ticketType);
        }

        //
        // GET: /TicketType/Create

        public ActionResult Create()
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            ViewBag.EventVenues = proxy.GetAllEventVenues();
            return View();
        }

        //
        // POST: /TicketType/Create

        [HttpPost]
        public ActionResult Create(TicketType ticketType)
        {
            if (ModelState.IsValid)
            {
                ITgiService proxy = new Proxy.ServiceProxy();
                proxy.CreatTicketType(ticketType);
            }
            return RedirectToAction("Index");
        }

        //
        // GET: /TicketType/Edit/5

        public ActionResult Edit(int id)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            var ticketType = proxy.GetTicketTypeById(id);
            ViewBag.EventVenues = proxy.GetAllEventVenues();
            return View(ticketType);
        }

        //
        // POST: /TicketType/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, TicketType ticketType)
        {
            if (ModelState.IsValid)
            {
                ITgiService proxy = new Proxy.ServiceProxy();
                proxy.UpdateTicketType(ticketType);
            }
            return RedirectToAction("Index");
        }

        //
        // GET: /TicketType/Delete/5

        public ActionResult Delete(int id)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            var ticketType = proxy.GetTicketTypeById(id);
            return View(ticketType);
        }

        //
        // POST: /TicketType/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, TicketType ticketType)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            proxy.DeleteTicketTypeById(id);
            return RedirectToAction("Index");
        }
    }
}
